home *** CD-ROM | disk | FTP | other *** search
-
-
- * * * >>>> IFF to WAV Converter <<<< * * *
- * *
- * Converts IFF samples to Windows' .WAV *
- * *
- * Written by Geert Coelmont on 9/1/93 *
- * This source is freely distributable *
- * as long as NOTHING's altered in ANY *
- * way. If you want more nice software *
- * then write me at: *
- * *
- * Eikenlaan 21 *
- * 3740 BILZEN *
- * B E L G I U M *
- * *
- * * * * * * * * * * * * * * * * * * * * * *
-
-
- IFFtoWAV:
- movem.l d0-a6,-(sp)
- subq.l #1,d0
- move.l d0,arglen
- move.l a0,argptr
-
- lea doslibrary(pc),a1
- moveq #0,d0
- move.l $4.w,a6
- jsr -408(a6) ; open library
- move.l d0,dosbase
-
- move.l d0,a6
- moveq #0,d0
- jsr -60(a6) ; find std_out
- move.l d0,texthandle
- beq error1
-
- CHECKPARAMETERS:
- move.l arglen(pc),d0
- tst.l d0
- beq.w error1
- subq.l #1,d0
- move.l argptr(pc),a0
- .loop: clr.l d2
- move.b (a0),d1
- cmp.b #"-",d1 ; check for switch
- bne.s checkfilenames
- move.b 1(a0),d1
- cmp.b #"8",d1 ; 8: 8 bit translation
- bne.w error1 ; else: illegal switch
- move.w #1,eightbit
- lea.l 3(a0),a0
- subq.l #3,d0
-
- CHECKFILENAMES:
- move.l a0,infilenameptr ; next param is Infile
- move.l d0,d1
- .loop1: cmp.b #32,(a0)+ ; find next space
- beq.s .exit1
- dbf d1,.loop1
- bra.w error1
- .exit1: clr.b -1(a0) ; terminate Infile
- move.l a0,outfilenameptr ; next param is Outfile
- tst.l d1
- ble.w error1
- .loop2: move.b (a0)+,d0
- cmp.b #32,d0 ; find eoln or next space
- beq.s .exit2
- cmp.b #10,d0
- beq.s .exit2
- dbf d1,.loop2
- bra.w error1
- .exit2: clr.b -1(a0) ; terminate Outfile
-
- OPENIN: move.l dosbase(pc),a6
- move.l infilenameptr(pc),d1
- move.l #1005,d2 ; 'MODE_OLDFILE'
- jsr -30(a6) ; open infile
- move.l d0,inhandle
- bne.s openout
-
- lea errorinfile(pc),a1
- move.l a1,textptr
- bra error1
-
- OPENOUT:move.l dosbase(pc),a6
- move.l outfilenameptr(pc),d1
- move.l #1006,d2 ; 'mode_newfile'
- jsr -30(a6) ; open outfile
- move.l d0,outhandle
- bne.s getinlength
-
- lea erroroutfile(pc),a1
- move.l a1,textptr
- bra error2
-
- GETINLENGTH:
- move.l infilenameptr(pc),d1
- moveq #-2,d2
- move.l dosbase(pc),a6
- jsr -84(a6) ; find lock
- move.l d0,lock
- move.l d0,d1
- move.l #infoblock,d2
- move.l dosbase(pc),a6
- jsr -102(a6) ; examine
- lea.l infoblock,a0
- move.l 124(a0),filelength
- move.l lock(pc),d1
- move.l dosbase(pc),a6
- jsr -90(a6) ; unlock
-
- ALLOCMEM:
- move.l filelength(pc),d0
- moveq #1,d1
- move.l $4.w,a6
- jsr -198(a6) ; alloc public memory
- move.l d0,dataptr
- bne.s readsample
-
- lea.l outofmem(pc),a1
- move.l a1,textptr
- bra.w error3
-
- READSAMPLE:
- move.l inhandle(pc),d1
- move.l dataptr(pc),d2
- move.l filelength(pc),d3
- move.l dosbase(pc),a6
- jsr -42(a6) ; read sample data
- bgt.s transformsample
-
- lea.l errorreading(pc),a1
- move.l a1,textptr
- bra.w error4
-
- TRANSFORMSAMPLE:
- move.l dataptr(pc),a0 ; adjust sample pitch for messy driver
- move.l filelength(pc),d0
- subq.l #1,d0
- move.w eightbit(pc),d2
- .loop: move.b (a0),d1
- tst.w d2 ; to six bit if not specified otherwise
- bne.s .skip
- asr.b #1,d1 ; transform to max 6 bit sampledata
- .skip: add.b #128,d1 ; zero -> 128 (they dont use a signbit)
- move.b d1,(a0)+ ; (yes sir it is crap!)
- subq.l #1,d0
- bne.s .loop
-
- move.l filelength(pc),d0 ; iffsample length
- sub.l #64-44,d0 ; min iff header (64)
- ; plus wav header (44)
-
- subq.l #8,d0 ; len 1st hunk=total length-headerlen
-
- lea.l global,a0 ; insert hunklength in hunk structure,
- move.b d0,(a0)+ ; msdos writes longwords right to left
- asr.l #8,d0 ; waccydos or what ?
- move.b d0,(a0)+
- asr.l #8,d0
- move.b d0,(a0)+
- asr.l #8,d0
- move.b d0,(a0)+
-
- move.l filelength(pc),d0
- sub.l #64,d0 ; length raw data (without IFF header)
- lea.l hunk2,a0 ; insert value in hunk structure
- move.b d0,(a0)+
- asr.l #8,d0
- move.b d0,(a0)+
- asr.l #8,d0
- move.b d0,(a0)+
- asr.l #8,d0
- move.b d0,(a0)+
-
- WRITEHEADER:
- move.l outhandle(pc),d1
- move.l #header,d2 ; write RIFF header (44 bytes)
- moveq #44,d3
- JSR -48(a6)
- bgt.s writesample
-
- lea.l errorwriting(pc),a1
- move.l a1,textptr
- bra.s error4
-
- WRITESAMPLE:
- move.l outhandle(pc),d1
- move.l dataptr(pc),d2 ; write processed sample data
- move.l filelength(pc),d3
- jsr -48(a6)
- bgt.s .ok1
-
- lea.l errorwriting(pc),a1
- move.l a1,textptr
- bra.s error4
-
- .ok1: move.l outhandle(pc),d1
- move.l #credits,d2 ; write credit string
- moveq #creditslength,d3
- jsr -48(a6)
- bgt.s validexit
-
- lea.l errorwriting(pc),a1
- move.l a1,textptr
- bra.s error4
-
- VALIDEXIT:
-
- move.l #valid,textptr
- error4:
- move.l dataptr(pc),a1
- move.l filelength(pc),d0
- move.l $4.w,a6
- jsr -210(a6) ; freemem
-
- error3:
- move.l dosbase(pc),a6
- move.l outhandle(pc),d1
- jsr -$24(a6) ; close outfile
- error2:
- move.l dosbase(pc),a6
- move.l inhandle(pc),d1
- jsr -$24(a6) ; close infile
- error1:
- move.l textptr(pc),a1
- bsr puttext
-
- move.l $4.w,a6
- move.l dosbase(pc),a1
- jsr -414(a6)
- movem.l (sp)+,d0-a6
- rts
-
- * * * * * * * *
-
- PUTTEXT:movem.l d0-a6,-(a7)
- move.l a1,d2
- moveq #0,d3
- .loop: addq #1,d3
- tst.b (a1)+
- bne.s .loop
- move.l texthandle(pc),d1
- beq.s .exit
- move.l dosbase(pc),a6
- jsr -48(a6) ; write text to stdout
- .exit: movem.l (a7)+,d0-a6
- rts
-
- * * * * * * * *
-
- dosbase: dc.l 0
- infilenameptr: dc.l 0
- outfilenameptr: dc.l 0
- inhandle: dc.l 0
- outhandle: dc.l 0
- texthandle: dc.l 0
- filelength: dc.l 0
- lock: dc.l 0
- dataptr: dc.l 0
- arglen: dc.l 0
- argptr: dc.l 0
- textptr: dc.l syntax
- eightbit: dc.w 0
- dc.l 0
-
- cnop 0,4
- infoblock: blk.b 260,0
-
- syntax: dc.b 10,27,"[0;33m IFFtoWAV © C00l-G'93",27,"[0m",10
- dc.b " Converts Amiga IFF samples to WinSLow's .WAV files",10,10
- dc.b " Usage: IFFtoWAV [-8] <infile> <outfile>",10
- dc.b " -8 forces 8 bit samples to be",10
- dc.b " created (default is 6 bit)",10,10,0
- errorinfile: dc.b "Error opening Input File...",10,10,0
- erroroutfile: dc.b "Error opening Output File...",10,10,0
- errorreading: dc.b "Error reading Input File...",10,10,0
- errorwriting: dc.b "Error writing Output File...",10,10,0
- outofmem: dc.b "Not enough memory !",10,10,0
- valid: dc.b 10," Your sample is now converted...",10
- dc.b " IFFtoWAV © C00l-G'93",10,10,0
- doslibrary: dc.b 'dos.library',0
- even
-
- header: dc.b "RIFF"
- global: dc.l 0 ; here comes the total length of the hunkdata
-
- dc.b "WAVEfmt "
- hunk1: dc.b 16,0,0,0 ; this hunk is always 16 bytes long
-
- dc.b $01,$00,$01,$00 ; the WAVEfmt hunk (no ID what it is used for!)
- dc.b $f8,$2a,$00,$00 ; better not change this...
- dc.b $f8,$2a,$00,$00
- dc.b $01,$00,$08,$00
-
- dc.b "data"
- hunk2: dc.l 0 ; here comes the length of the samplehunk
-
-
- credits:dc.b "This sample was converted from AMIGA using C00l-G's "
- dc.b "IFFtoWAV -- AMIGA: your imagination is "
- dc.b "the ONLY limit !"
-
- endc:
- creditslength= endc-credits
-